package com.xzy.sms.web.domain.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Where;

import com.xzyframework.persistence.BaseEntity;

/**
 * @desc 应用实体
 * @author wjw
 * @time 2017年11月16日下午3:31:26
 */
@Entity
@Table(name = "pub_application")
public class Application extends BaseEntity {
    
    /** 序列化 */
    private static final long serialVersionUID = -936203994181527906L;
    
    /** 主键id，也是applicationId */
    @Id
    @GeneratedValue(generator = "UIDGenerator")
    @GenericGenerator(name = "UIDGenerator", strategy = "com.xzyframework.persistence.UIDGenerator")
    @Column(length = 40)
    private String applicationId;
    
    /** 应用名 */
    @NotNull(message = "应用名不能为空")
    @NotBlank(message = "应用名不能为空")
    @Column(length = 40)
    private String name;
    
    /** 应用描述 */
    @Column(length = 500)
    private String description;
    
    /** 私钥 */
    @Column(length = 100, updatable = false)
    private String secretKey;
    
    /** 发送通道 */
    private String channelId;
    
    /** 所属用户 */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", updatable = false, nullable = true)
    @Where(clause = "del_flag='" + DEL_FLAG_NORMAL + "'")
    @NotNull
    private User user;
    
    /**
     * 构造函数
     */
    public Application() {
    }
    
    /**
     * 构造函数
     * 
     * @param applicationId x
     */
    public Application(String applicationId) {
        this.applicationId = applicationId;
    }
    
    /**
     * @return the applicationId
     */
    public String getApplicationId() {
        return applicationId;
    }
    
    /**
     * @param applicationId the applicationId to set
     */
    public void setApplicationId(String applicationId) {
        this.applicationId = applicationId;
    }
    
    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
    
    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /**
     * @return the secretKey
     */
    public String getSecretKey() {
        return secretKey;
    }
    
    /**
     * @param secretKey the secretKey to set
     */
    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }
    
    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }
    
    /**
     * @return the channelId
     */
    public String getChannelId() {
        return channelId;
    }
    
    /**
     * @param channelId the channelId to set
     */
    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }
    
    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }
    
    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }
    
}
